package com.lagou.utils;


import com.lagou.annotations.AutoWired;
import com.lagou.annotations.Component;

@Component("transactionManager")
public class TransactionManager {
    @AutoWired
    private ConnectionUtils connectionUtils;

    // 开启事务
    public void beginTransaction() throws Exception {
        connectionUtils.getCurrentThreadConnection().setAutoCommit(false);
    }

    // 提交事务
    public void commit() throws Exception {
        connectionUtils.getCurrentThreadConnection().commit();
    }

    //回滚事务
    public void rollback() throws Exception {
        connectionUtils.getCurrentThreadConnection().rollback();
    }
}
